<% if organization %>
  <% if defined?(custom_url_for_mail_root) && custom_url_for_mail_root.present? %>
    <% url = custom_url_for_mail_root %>
  <% else %>
    <% url = decidim.root_url(host: organization.host) %>
  <% end %>
  <%= link_to url do %>
    <% if organization.logo.attached? %>
      <%= image_tag(
            organization.attached_uploader(:logo).variant_url(:medium, host: organization.host),
            style: "max-height: 50px",
            alt: organization_name(organization)
          ) %>
    <% else %>
      <span><%= organization_name(organization) %></span>
    <% end %>
  <% end %>
<% else %>
  <%= Decidim.application_name %>
<% end %>
